import type * as T from './type'
import http from '@/utils/http'

export type * from './type'

/**
 * 存储分页
 * @param query
 */
export function pageStorage(query: T.StoragePageQuery) {
  return http.get<PageRes<T.StorageResp[]>>(`/system/storage`, query)
}

/**
 * 存储详情
 * @param id
 */
export function getStorage(id: string) {
  return http.get<T.StorageResp>(`/system/storage/${id}`)
}

/**
 * 新增存储
 * @param data
 */
export function addStorage(data: any) {
  return http.post(`/system/storage`, data)
}

/**
 * 修改存储
 * @param data
 * @param id
 */
export function updateStorage(data: any, id: string) {
  return http.put(`/system/storage/${id}`, data)
}

/**
 * 删除存储
 * @param id
 */
export function deleteStorage(id: string) {
  return http.del(`/system/storage/${id}`)
}

/**
 * 修改存储状态
 * @param data
 * @param id
 */
export function updateStorageStatus(data: any, id: string) {
  return http.put(`/system/storage/${id}/status`, data)
}

/**
 * 设置默认存储
 * @param id
 */
export function setDefaultStorage(id: string) {
  return http.put(`/system/storage/${id}/default`)
}
